import QtQuick 2.0
import QtQuick.Particles 2.0

//emitter 不能批量创建
Item {
    id:root

    MouseArea{
        id:mouse
        anchors.fill: parent
        cursorShape: Qt.BlankCursor     //隐藏光标
        hoverEnabled: true
        onPositionChanged: {
            var tempX = mouse.x - coustomCusor.width
            var tempY = mouse.y - coustomCusor.height
            if(!root.contains(Qt.point(tempX,tempY))){
                return ;
            }

            //移动光标图片到光标位置
            coustomCusor.x = tempX
            coustomCusor.y = tempY

            emitter1.x = coustomCusor.x
            emitter1.y = coustomCusor.y

            emitter2.x = coustomCusor.x
            emitter2.y = coustomCusor.y
        }

        Image {
            id: coustomCusor
            source: "qrc:/EpChristmas/UI/mbang.png"
        }
    }

    Item {
        id: stopArea
        width: parent.width
        height: 20
        anchors.bottom: parent.bottom

        Rectangle {
            anchors.fill: parent
            border.color: "red"
            border.width: 1
        }

    }

    //角度方向
    AngleDirection{
        id: angleDirect
        angle: 120
        angleVariation: 30
        magnitude: root.height / 4 //3秒飘出屏幕
        magnitudeVariation: 10
    }

    ParticleSystem {
        id: particles
        anchors.fill: parent

        Emitter {
            id:emitter1
            group: "stars"
            emitRate: 10
            lifeSpan: 4000
            enabled: true
            size: 30
            sizeVariation: 10
            endSize:50
            velocity: angleDirect
            acceleration: angleDirect
//            onEmitParticles: {
//                console.log("emit");
//                console.log(particles);
//                var index = Math.floor(Math.random()*listModel.count);
//                stars.source = listModel.get(index).src;
//            }
        }
        Emitter {
            id:emitter2
            width: parent.width
            height: 20
            anchors.top: parent.top
            group: "roids"
            emitRate: 10
            lifeSpan: 4000
            enabled: true
            size: 30
            sizeVariation: 10
            endSize:50
            velocity: angleDirect
            acceleration: angleDirect

        }
        ImageParticle {
            id: stars
            groups: ["stars"]
            source: "qrc:///EpChristmas/UI/liwu-01.png"
        }
        ImageParticle {
            id: roids
            groups: ["roids"]
            source: "qrc:///EpChristmas/UI/weibiaoti-2_fuzhi_lingdang.png"
        }
    }

    ListModel{
        id:listModel
        ListElement{grp:"1";src:"qrc:/EpChristmas/UI/weibiaoti-2_fuzhi_shengdanmao.png"}
        ListElement{grp:"2";src:"qrc:/EpChristmas/UI/liwu-01.png"}
        ListElement{grp:"3";src:"qrc:/EpChristmas/UI/weibiaoti-2_fuzhi_aixin_1.png"}
        ListElement{grp:"4";src:"qrc:/EpChristmas/UI/weibiaoti-2_fuzhi_wazi-30.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/weibiaoti-2_fuzhi_wazi-07.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/weibiaoti-2_fuzhi_guoshi.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/a-weibiaoti-3_fuzhi_huaban1_fuzhi-01_2.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/a-weibiaoti-3_fuzhi_huaban1_fuzhi-01_1.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/a-weibiaoti-3_fuzhi_huaban1_fuzhi-01_4.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/a-weibiaoti-3_fuzhi_huaban1_fuzhi-01_3.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/a-weibiaoti-3_fuzhi_huaban1_fuzhi-01_5.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/weibiaoti-2_fuzhi_aixin.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/weibiaoti-2_fuzhi_xueren.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/weibiaoti-2_fuzhi_xuehua.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/weibiaoti-2_fuzhi_lingdang.png"}
//        ListElement{grp:"";src:"qrc:/EpChristmas/UI/weibiaoti-2_fuzhi_lutou.png"}
    }


}
